package servlet;

import java.io.IOException;
import java.sql.SQLException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import action.common.RepertoryAction;
import action.common.StockPlanAction;
import dateChange.DateChage;
import model.common.Repertory;
import model.common.StockPlan;

public class EditRepertory extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    public EditRepertory() {
        super();
    }
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doPost(request, response);}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
        response.setContentType("text/html; charset=utf-8");
        
       RepertoryAction act=new RepertoryAction();
       Repertory r=new Repertory();
        
        r.setGoodsName(request.getParameter("goodsName"));
        r.setGoodsRepertoryNumber(Integer.parseInt(request.getParameter("goodsRepertoryNumber")));
        r.setGoodsUnitPrice(Double.parseDouble( request.getParameter("goodsUnitPrice")));
        r.setGoodsPrice(Double.parseDouble( request.getParameter("goodsPrice")));
        r.setGoodsManufacturer(request.getParameter("goodsManufacturer"));
        r.setGoodsProductionDate(DateChage.StringToDate(request.getParameter("goodsProductionDate")));
        r.setGoodsExpirationDate(DateChage.StringToDate(request.getParameter("goodsExpirationDate")));
        r.setGoodsStockDate(DateChage.StringToDate(request.getParameter("goodsStockDate")));
        r.setGoodsId(Integer.parseInt(request.getParameter("id")));
        try {
			act.edit(r);
			System.out.println("a");
			response.sendRedirect("repertory1.jsp");
		} catch (SQLException e) {
			e.printStackTrace();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	}

